package com.cc.comm;

import lombok.Data;

@Data
public class R<T> {
    /**
     * 状态码
     */
    private Integer code;
    /**
     * 状态信息
     */
    private Boolean status;
    /**
     * 返回信息
     */
    private String message;
    /**
     * 数据
     */
    private T data;


    public static R ok(Object data) {
        R r = new R();
        r.setCode(HttpStatusEnum.OK.getCode());
        r.setMessage(HttpStatusEnum.OK.getMessage());
        r.setStatus(true);
        r.setData(data);


        return r;
    }


    public static R error(String message) {
        R r = new R();
        r.setCode(HttpStatusEnum.BAD_REQUEST.getCode());
        r.setMessage(message);
        r.setStatus(false);
        r.setData(null);
        return r;
    }
}
